package com.ds.infrastructure.hyperspace.container.flow.operation;

import com.ds.infrastructure.hyperspace.common.StateEnum;
import com.ds.infrastructure.hyperspace.common.flow.DuplexFlowContext;

/**
 * @author  Weishaoying
 */
public interface FlowOperation<C extends DuplexFlowContext> {

    /**
     * interrupt current request
     * @param duplexFlowContext
     * @param state
     * @param message
     */
    void interruptAndCloseContext(C duplexFlowContext, StateEnum state, String message);

    /**
     * Handle out put data
     * @param duplexFlowContext
     * @param data
     */
    void handleOutput(C duplexFlowContext, Object data);

    /**
     * Handle out put data complete
     * @param duplexFlowContext
     */
    void handleOutputComplete(C duplexFlowContext);

    /**
     * Calculate message byte size
     * @param msg
     * @return
     */
    int calculateMessageSize(Object msg);

}
